package com.lanhe.common.constant;

import com.google.common.collect.ImmutableMap;
import io.jsonwebtoken.Claims;

import java.util.Map;

/**
 * 通用常量信息
 *
 * @author lanhe
 */
public class Constants
{
    /**
     * UTF-8 字符集
     */
    public static final String UTF8 = "UTF-8";

    /**
     * GBK 字符集
     */
    public static final String GBK = "GBK";

    /**
     * www主域
     */
    public static final String WWW = "www.";

    /**
     * http请求
     */
    public static final String HTTP = "http://";

    /**
     * https请求
     */
    public static final String HTTPS = "https://";

    /**
     * 通用成功标识
     */
    public static final String SUCCESS = "0";

    /**
     * 通用失败标识
     */
    public static final String FAIL = "1";

    /**
     * 登录成功
     */
    public static final String LOGIN_SUCCESS = "Success";

    /**
     * 注销
     */
    public static final String LOGOUT = "Logout";

    /**
     * 注册
     */
    public static final String REGISTER = "Register";

    /**
     * 登录失败
     */
    public static final String LOGIN_FAIL = "Error";

    /**
     * 所有权限标识
     */
    public static final String ALL_PERMISSION = "*:*:*";

    /**
     * 管理员角色权限标识
     */
    public static final String SUPER_ADMIN = "admin";

    /**
     * 角色权限分隔符
     */
    public static final String ROLE_DELIMETER = ",";

    /**
     * 权限标识分隔符
     */
    public static final String PERMISSION_DELIMETER = ",";

    /**
     * 验证码有效期（分钟）
     */
    public static final Integer CAPTCHA_EXPIRATION = 2;

    /**
     * 令牌
     */
    public static final String TOKEN = "token";

    /**
     * 令牌前缀
     */
    public static final String TOKEN_PREFIX = "Bearer ";

    /**
     * 令牌前缀
     */
    public static final String LOGIN_USER_KEY = "login_user_key";

    /**
     * 系统标识字段
     */
    public static final String DETAILS_SYS_FLAG = "sys_flag";

    /**
     * 用户ID
     */
    public static final String JWT_USERID = "userid";

    /**
     * 用户名称
     */
    public static final String JWT_USERNAME = Claims.SUBJECT;

    /**
     * 用户头像
     */
    public static final String JWT_AVATAR = "avatar";

    /**
     * 创建时间
     */
    public static final String JWT_CREATED = "created";

    /**
     * 用户权限
     */
    public static final String JWT_AUTHORITIES = "authorities";

    /**
     * 资源映射路径 前缀
     */
    public static final String RESOURCE_PREFIX = "/profile";

    /**
     * RMI 远程方法调用
     */
    public static final String LOOKUP_RMI = "rmi:";

    /**
     * LDAP 远程方法调用
     */
    public static final String LOOKUP_LDAP = "ldap:";

    /**
     * LDAPS 远程方法调用
     */
    public static final String LOOKUP_LDAPS = "ldaps:";

    /**
     * API
     */
    public static final String API = "/api";

    /**
     * 自动识别json对象白名单配置（仅允许解析的包名，范围越小越安全）
     */
    public static final String[] JSON_WHITELIST_STR = { "org.springframework", "com.lanhe" };

    /**
     * 定时任务白名单配置（仅允许访问的包名，如其他需要可以自行添加）
     */
    public static final String[] JOB_WHITELIST_STR = { "com.lanhe" };

    /**
     * 定时任务违规的字符
     */
    public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
            "org.springframework", "org.apache", "com.lanhe.common.utils.file", "com.lanhe.common.config" };

    /** 校验是否唯一的返回标识 */
    public final static boolean UNIQUE = true;
    public final static boolean NOT_UNIQUE = false;

    public static final Map<String,String> IDENTIFIER_BIND_PLATFORM = ImmutableMap.of("1","微信", "2","支付宝");
    public static final Map<String,String> IDENTIFIER_BIND_IS_USE = ImmutableMap.of("0","未使用", "2","已使用");
    public static final Map<String,String> IDENTIFIER_BIND_STATUS = ImmutableMap.of("0","正常", "2","禁用");

    public static final Integer ORDERS_ORIGIN_DUOYOU = 0; //多游
    public static final Integer ORDERS_ORIGIN_QINGCHUANG = 1; //清创
    public static final Integer ORDERS_ORIGIN_KAYU = 2; //卡鱼
    public static final Integer ORDERS_ORIGIN_HAOKA = 3; //号卡


    public static final Integer ORDERS_REVENUE_TYPE_0 = 0; //订单收益类型-订单收益
    public static final Integer ORDERS_REVENUE_TYPE_1 = 1; //订单收益类型-充值收益


    public static final Integer APPLY_STATUS_0 = 0; // 待通过
    public static final Integer APPLY_STATUS_1 = 1; // 审核通过
    public static final Integer APPLY_STATUS_2 = 2; // 审核失败
    public static final Integer APPLY_STATUS_3 = 3; // 超时失效(部分产品链接有使用时效,超过失效未提交作业数据该条报备信息及链接会失效)




    /**
     * 通用，只是为了不让代码出现魔法值
     * 具体含义根据自行业务判断
     */
    public static class GeneralIntType {
        /**
         * 0
         */
        public static Integer ZERO = 0;
        /**
         * 1
         */
        public static Integer ONE = 1;
        /**
         * 2
         */
        public static Integer TWO = 2;
        /**
         * 3
         */
        public static Integer THREE = 3;
        /**
         * 4
         */
        public static Integer FOUR = 4;

        public static Integer MINUS_FOUR = -4;
        /**
         * 5
         */
        public static Integer FIVE = 5;
        /**
         * 6
         */
        public static Integer SIX = 6;
        /**
         * 7
         */
        public static Integer SEVEN = 7;
        /**
         * 8
         */
        public static Integer EIGHT = 8;
        /**
         * 9
         */
        public static Integer NINE = 9;

        public static Integer TEN = 10;

        public static Integer N_TEN = -10;

        public static Integer TWENTY = 20;

        public static Integer THIRTY = 30;

        public static Integer FORTY = 40;

        public static Integer NINETY_NINE = 99;

        public static Integer ONE_HUNDRED_ONE = 101;

        public static Integer TWO_HUNDRED = 200;

        public static Integer TEN_THOUSAND = 10000;
    }


    //订单状态0:已通过(表示二卡不可结算),1:已完成(可结算正常奖励),2:降级通过 (可结算降级奖励),3:额外通过 (可结算额外奖励)
    public static final String APPLY_KAYU_STATUS_0 = "0";
    public static final String APPLY_KAYU_STATUS_1 = "1";
    public static final String APPLY_KAYU_STATUS_2 = "2";
    public static final String APPLY_KAYU_STATUS_3 = "3";

    /**
     * 卡鱼状态
     *
     * @author zhanggl
     * @since 2023-12-24
     */
    public enum KayuStatus{

        /** 类型码 */
        KayuStatus_0(APPLY_KAYU_STATUS_0,"已通过"),
        KayuStatus_1(APPLY_KAYU_STATUS_1,"已完成"),
        KayuStatus_2(APPLY_KAYU_STATUS_2,"降级通过"),
        KayuStatus_3(APPLY_KAYU_STATUS_3,"额外通过");

        private final String key;
        private final String value;

        public String getKey () {
            return key;
        }

        public String getValue () {
            return value;
        }



        KayuStatus(String key, String value) {
            this.key = key;
            this.value = value;
        }

        /**
         * 卡鱼回调类型
         *
         * @param key KEY
         * @return value
         */
        public static String getKayuStatus(String key){

            for (KayuStatus type : KayuStatus.values()) {
                if (type.getKey().equals(key)) {
                    return type.getValue();
                }
            }
            return "";
        }
    }


    /**
     * 号卡类型
     *
     * @author zhanggl
     * @since 2023-12-25
     */
    //类型，1=联通,2=移动,3=电信,4=广电
    public static final Integer HAOKA_TYPE_1 = 1;
    public static final Integer HAOKA_TYPE_2 = 2;
    public static final Integer HAOKA_TYPE_3 = 3;
    public static final Integer HAOKA_TYPE_4 = 4;
    public enum HaokaType{

        /** 类型码 */
        HaokaType_1(HAOKA_TYPE_1,"联通"),
        HaokaType_2(HAOKA_TYPE_2,"移动"),
        HaokaType_3(HAOKA_TYPE_3,"电信"),
        HaokaType_4(HAOKA_TYPE_4,"广电");

        private final Integer key;
        private final String value;

        public Integer getKey () {
            return key;
        }

        public String getValue () {
            return value;
        }

        HaokaType(Integer key, String value) {
            this.key = key;
            this.value = value;
        }

        /**
         * 卡鱼回调类型
         *
         * @param key KEY
         * @return value
         */
        public static String getHaokaTypeName(Integer key){

            for (HaokaType type : HaokaType.values()) {
                if (type.getKey().equals(key)) {
                    return type.getValue();
                }
            }
            return "";
        }
    }

    /**
     * 号卡订单状态
     *
     * @author zhanggl
     * @since 2023-12-25
     */
    //订单状态0:已发货,1:已激活,2:开卡失败,3:身份证审核失败,4:订单终止
    public static final String ORDERS_HAOKA_STATUS_0 = "0";
    public static final String ORDERS_HAOKA_STATUS_1 = "1";
    public static final String ORDERS_HAOKA_STATUS_2 = "2";
    public static final String ORDERS_HAOKA_STATUS_3 = "3";
    public static final String ORDERS_HAOKA_STATUS_4 = "4";
    public enum HaokaOrderStatus{

        /** 类型码 */
        HaokaOrderStatus_0(ORDERS_HAOKA_STATUS_0,"已发货"),
        HaokaOrderStatus_1(ORDERS_HAOKA_STATUS_1,"已激活"),
        HaokaOrderStatus_2(ORDERS_HAOKA_STATUS_2,"开卡失败"),
        HaokaOrderStatus_3(ORDERS_HAOKA_STATUS_3,"身份证审核失败"),
        HaokaOrderStatus_4(ORDERS_HAOKA_STATUS_4,"订单终止");

        private final String key;
        private final String value;

        public String getKey () {
            return key;
        }

        public String getValue () {
            return value;
        }

        HaokaOrderStatus(String key, String value) {
            this.key = key;
            this.value = value;
        }

        public static String getHaokaOrderStatusName(String key){

            for (HaokaOrderStatus type : HaokaOrderStatus.values()) {
                if (type.getKey().equals(key)) {
                    return type.getValue();
                }
            }
            return "";
        }
    }

    /**
     * 号卡订单审核状态
     *
     * @author zhanggl
     * @since 2024年01月04日15:56:05
     */
    public enum HaokaOrderAuditStatus{

        /** 类型码 */
        HaokaOrderAuditStatus_1(1,"待审核"),
        HaokaOrderAuditStatus_2(2,"已审核"),
        HaokaOrderAuditStatus_3(3,"审核拒绝");

        private final Integer key;
        private final String value;

        public Integer getKey () {
            return key;
        }

        public String getValue () {
            return value;
        }

        HaokaOrderAuditStatus(Integer key, String value) {
            this.key = key;
            this.value = value;
        }

        public static String getHaokaOrderAuditStatusName(Integer key){

            for (HaokaOrderAuditStatus type : HaokaOrderAuditStatus.values()) {
                if (type.getKey().equals(key)) {
                    return type.getValue();
                }
            }
            return "";
        }
    }

    /**
     * 主订单源类型
     *
     * @author zhanggl
     * @since 2023年12月27日23:06:18
     */
    public enum OrdersOriginType{

        /** 类型码 */
        OrdersOriginType_0(ORDERS_ORIGIN_DUOYOU,"多量"),
        OrdersOriginType_1(ORDERS_ORIGIN_QINGCHUANG,"拉新"),
        OrdersOriginType_2(ORDERS_ORIGIN_KAYU,"初审"),
        OrdersOriginType_3(ORDERS_ORIGIN_HAOKA,"号卡");

        private final Integer key;
        private final String value;

        public Integer getKey () {
            return key;
        }

        public String getValue () {
            return value;
        }

        OrdersOriginType(Integer key, String value) {
            this.key = key;
            this.value = value;
        }

        public static String getOrdersOriginTypeName(Integer key){

            for (OrdersOriginType type : OrdersOriginType.values()) {
                if (type.getKey().equals(key)) {
                    return type.getValue();
                }
            }
            return "";
        }
    }

    /**
     * 主订单源状态
     *
     * @date 2023年12月27日23:06:18
     */
    // 订单状态0:已通过(表示二卡不可结算),1:已完成(可结算正常奖励),2:降级通过 (可结算降级奖励),3:额外通过 (可结算额外奖励)
    public static final String ORDERS_POOL_STATUS_0 = "0";
    public static final String ORDERS_POOL_STATUS_1 = "1";
    public enum PoolOrderStatus{

        /** 类型码 */
        OrdersPoolStatus_0(ORDERS_POOL_STATUS_0,"未处理"),
        OrdersPoolStatus_1(ORDERS_POOL_STATUS_1,"已结算");

        private final String key;
        private final String value;

        public String getKey () {
            return key;
        }

        public String getValue () {
            return value;
        }

        PoolOrderStatus(String key, String value) {
            this.key = key;
            this.value = value;
        }

        public static String getPoolStatusName(String key){

            for (PoolOrderStatus type : PoolOrderStatus.values()) {
                if (type.getKey().equals(key)) {
                    return type.getValue();
                }
            }
            return "";
        }
    }

    /**
     * 清创订单状态
     *
     * @author zhanggl
     * @since 2023年12月27日23:44:04
     */
    //订单状态0:已发货,1:已激活
    public static final String ORDERS_QINGCHUANG_STATUS_0 = "待处理";
    public static final String ORDERS_QINGCHUANG_STATUS_1 = "已结算";
    public static final String ORDERS_QINGCHUANG_STATUS_2 = "未通过";
    public enum QingchuangOrderStatus{

        /** 类型码 */
        HaokaOrderStatus_0(ORDERS_QINGCHUANG_STATUS_0,"待处理"),
        HaokaOrderStatus_1(ORDERS_QINGCHUANG_STATUS_1,"已结算"),
        HaokaOrderStatus_2(ORDERS_QINGCHUANG_STATUS_2,"未通过");

        private final String key;
        private final String value;

        public String getKey () {
            return key;
        }

        public String getValue () {
            return value;
        }

        QingchuangOrderStatus(String key, String value) {
            this.key = key;
            this.value = value;
        }

        public static String getQingchuangOrderStatusName(String key){

            for (HaokaOrderStatus type : HaokaOrderStatus.values()) {
                if (type.getKey().equals(key)) {
                    return type.getValue();
                }
            }
            return "";
        }
    }

    // 支付平台：0未知，1线下支付，2微信支付，3支付宝,4积分支付
    public static final Integer PLATFORM_0 = 0;
    public static final Integer PLATFORM_1 = 1;
    public static final Integer PLATFORM_2 = 2;
    public static final Integer PLATFORM_3 = 3;
    public static final Integer PLATFORM_4 = 4;

    // 是否付款：0未付款，1已付款
    public static final Integer PAYED_NO = 0;
    public static final Integer PAYED_YES = 1;


    /**
     * 支付订单状态
     *
     * @author zhanggl
     * @since 2024年01月05日21:45:15
     */
    public enum OrdersPayedStatus{

        /** 类型码 */
        OrdersPayedStatus_1(PAYED_NO,"待提现"),
        OrdersPayedStatus_2(PAYED_YES,"已提现");

        private final Integer key;
        private final String value;

        public Integer getKey () {
            return key;
        }

        public String getValue () {
            return value;
        }



        OrdersPayedStatus(Integer key, String value) {
            this.key = key;
            this.value = value;
        }

        /**
         * 付款状态类型
         *
         * @param key KEY
         * @return value
         */
        public static String getOrdersPayedStatusName(Integer key){

            for (OrdersPayedStatus type : OrdersPayedStatus.values()) {
                if (type.getKey().equals(key)) {
                    return type.getValue();
                }
            }
            return "";
        }
    }


    /**
     * 提现订单状态
     *
     * @author zhanggl
     * @since 2024年01月05日21:45:15
     */
    public static final Integer ORDERS_WITHDRAWAL_STATUS_1 = 1;
    public static final Integer ORDERS_WITHDRAWAL_STATUS_2 = 2;
    public static final Integer ORDERS_WITHDRAWAL_STATUS_3 = 3;
    public enum OrdersWithdrawalStatus{

        /** 类型码 */
        OrdersWithdrawalStatus_1(ORDERS_WITHDRAWAL_STATUS_1,"待审核"),
        OrdersWithdrawalStatus_2(ORDERS_WITHDRAWAL_STATUS_2,"审核通过"),
        OrdersWithdrawalStatus_3(ORDERS_WITHDRAWAL_STATUS_3,"审核拒绝");

        private final Integer key;
        private final String value;

        public Integer getKey () {
            return key;
        }

        public String getValue () {
            return value;
        }



        OrdersWithdrawalStatus(Integer key, String value) {
            this.key = key;
            this.value = value;
        }

        /**
         * 提现类型
         *
         * @param key KEY
         * @return value
         */
        public static String getOrdersWithdrawalStatusName(Integer key){

            for (OrdersWithdrawalStatus type : OrdersWithdrawalStatus.values()) {
                if (type.getKey().equals(key)) {
                    return type.getValue();
                }
            }
            return "";
        }
    }


    /**
     * 会员采购类型
     *
     * @author zhanggl
     * @date 2024年01月17日16:53:45
     */
    public static final Integer PURCHASE_TYPE_1 = 1;
    public static final Integer PURCHASE_TYPE_2 = 2;
    public static final Integer PURCHASE_TYPE_3 = 3;
    public enum PurchaseType{

        /** 类型码 */
        PURCHASE_TYPE_01(PURCHASE_TYPE_1,"金币"),
        PURCHASE_TYPE_02(PURCHASE_TYPE_2,"积分"),
        PURCHASE_TYPE_03(PURCHASE_TYPE_3,"商务");

        private final Integer key;
        private final String value;

        public Integer getKey () {
            return key;
        }

        public String getValue () {
            return value;
        }

        PurchaseType(Integer key, String value) {
            this.key = key;
            this.value = value;
        }

        /**
         * 采购类型
         *
         * @param key KEY
         * @return value
         */
        public static String getPurchaseTypeName(Integer key){

            for (PurchaseType type : PurchaseType.values()) {
                if (type.getKey().equals(key)) {
                    return type.getValue();
                }
            }
            return "";
        }
    }


    /**
     * 会员采购订单类型
     *
     * @author zhanggl
     * @date 2024年01月17日20:00:04
     */
    public static final Integer ORDER_TYPE_1 = 1;
    public static final Integer ORDER_TYPE_2 = 2;
    public enum OrderType{

        /** 类型码 */
        ORDER_TYPE_01(ORDER_TYPE_1,"购买"),
        ORDER_TYPE_02(ORDER_TYPE_2,"续费");

        private final Integer key;
        private final String value;

        public Integer getKey () {
            return key;
        }

        public String getValue () {
            return value;
        }

        OrderType(Integer key, String value) {
            this.key = key;
            this.value = value;
        }

        /**
         * 采购订单类型
         *
         * @param key KEY
         * @return value
         */
        public static String getOrderTypeName(Integer key){

            for (OrderType type : OrderType.values()) {
                if (type.getKey().equals(key)) {
                    return type.getValue();
                }
            }
            return "";
        }
    }

}
